package com.sgb.kjwl.model.entity.self;

import android.os.Parcel;
import android.os.Parcelable;

import com.contrarywind.interfaces.IPickerViewData;

/**
 * Describe:
 * Author:  yangLei
 * Date:    2021/6/22
 */
public class TypeChooseEntity implements IPickerViewData, Parcelable {

    private String no;
    /**
     * 功能名称
     */
    private String name;
    /**
     * 排序
     */
    private Integer sort;

    /**
     * 是否被选中
     */
    private boolean isSelect;

    private int number = 0;

    private float minValue;
    private float maxValue;

    public TypeChooseEntity(String no, String name) {
        this.no = no;
        this.name = name;
    }

    public TypeChooseEntity(String name, float minValue, float maxValue) {
        this.name = name;
        this.minValue = minValue;
        this.maxValue = maxValue;
    }

    public TypeChooseEntity() {
    }

    protected TypeChooseEntity(Parcel in) {
        no = in.readString();
        name = in.readString();
        if (in.readByte() == 0) {
            sort = null;
        } else {
            sort = in.readInt();
        }
        isSelect = in.readByte() != 0;
        number = in.readInt();
        minValue = in.readFloat();
        maxValue = in.readFloat();
    }

    public static final Creator<TypeChooseEntity> CREATOR = new Creator<TypeChooseEntity>() {
        @Override
        public TypeChooseEntity createFromParcel(Parcel in) {
            return new TypeChooseEntity(in);
        }

        @Override
        public TypeChooseEntity[] newArray(int size) {
            return new TypeChooseEntity[size];
        }
    };

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public boolean isSelect() {
        return isSelect;
    }

    public void setSelect(boolean select) {
        isSelect = select;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public float getMinValue() {
        return minValue;
    }

    public void setMinValue(float minValue) {
        this.minValue = minValue;
    }

    public float getMaxValue() {
        return maxValue;
    }

    public void setMaxValue(float maxValue) {
        this.maxValue = maxValue;
    }

    @Override
    public String getPickerViewText() {
        return name == null ? "不限" : name;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(no);
        dest.writeString(name);
        if (sort == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(sort);
        }
        dest.writeByte((byte) (isSelect ? 1 : 0));
        dest.writeInt(number);
        dest.writeFloat(minValue);
        dest.writeFloat(maxValue);
    }

    @Override
    public String toString() {
        return "TypeChooseEntity{" +
                "no='" + no + '\'' +
                ", name='" + name + '\'' +
                ", sort=" + sort +
                ", isSelect=" + isSelect +
                ", number=" + number +
                ", minValue=" + minValue +
                ", maxValue=" + maxValue +
                '}';
    }
}
